﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
using TTGameEngine;
using UnityEngine.UI;

public class UIFloatMsgData : UIDataBase {
    public string msg;

    public UIFloatMsgData(string msg) {
        this.msg = msg;
    }
}

public class UIFloatMsg : UIBase {
    public RectTransform m_mainNodeTF;
    public float MoveUpDis = 10f;
    public float MoveUpTime = 0.5f;
    public Text m_text;
    [SerializeField]
    Vector3 startPos;
    Vector3 endPos;
    UIFloatMsgData m_uidata;

    public override void init() {
        m_uidata = (UIFloatMsgData)m_uidatabase;
        m_text.text = m_uidata.msg;
        MoveUpAndHideNode();
    }

    void MoveUpAndHideNode() {
        if(m_mainNodeTF == null) {
            return;
        }
        m_mainNodeTF.localPosition = startPos;
        endPos = startPos + new Vector3(0, MoveUpDis, 0);
        Tweener tw = m_mainNodeTF.DOLocalMove(endPos, MoveUpTime);
        tw.SetEase(Ease.Linear);
        tw.onComplete = () => {
            CloseSelf();
        };
    }



}
